﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.FactoryUI {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import flash.geom.*;
    import org.aswing.*;
    import Classes.*;
    import com.greensock.*;
    import Display.*;
    import Display.aswingui.*;
    import com.greensock.easing.*;

    public class SlidePick extends Sprite {

        public static const VISIBLE:int = 0;
        public static const VISIBLE_ON_ROLLOVER:int = 1;
        public static const NOT_VISIBLE:int = 2;
        public static const USE_BG_WIDTH:int = -1;
        public static const DEFAULT_PICK_WIDTH:int = 62;
        public static const DEFAULT_PICK_HEIGHT:int = 77;
        public static const PICK_WIDTH_OFFSET:int = 15;
        public static const INNER_Y_OFFSET:int = 3;
        public static const HEIGHT_OFFSET:int = 20;

        protected var m_jw:JWindow;
        protected var m_innerWindow:JWindow;
        protected var m_jpanel:JPanel;
        protected var m_innerPanel:JPanel;
        protected var m_icon:Bitmap;
        protected var m_assetPane:AssetPane;
        protected var m_mainSprite:Sprite;
        protected var m_innerSprite:Sprite;
        protected var m_innerMask:Sprite;
        protected var m_offXPos:int;
        protected var m_bgAsset:DisplayObject;
        protected var m_visibility:int;
        protected var m_tween:TimelineLite;
        protected var m_sliderActive:Boolean;
        protected var m_animationActive:Boolean;
        protected var m_modal:Boolean;
        protected var m_slideWidth:int;
        protected var m_iconBackground:Sprite;
        protected var m_asset:Loader;

        public function SlidePick(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=true, _arg4:int=0, _arg5:Boolean=false, _arg6:int=-1){
            this.m_slideWidth = _arg6;
            this.m_innerPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            this.init(_arg1);
            this.initPick();
            this.initInner();
            this.m_innerSprite.x = -(this.slideWidth);
            this.m_offXPos = -(this.slideWidth);
            this.m_innerWindow.setX(this.pickWidth);
            this.m_innerWindow.setY(INNER_Y_OFFSET);
            this.m_innerWindow.setContentPane(this.m_innerPanel);
            this.prepareWindow();
            this.redrawMask();
            this.m_innerWindow.show();
            this.m_sliderActive = _arg2;
            this.m_visibility = _arg4;
            this.m_modal = _arg5;
            this.m_tween = new TimelineLite({onComplete:this.onAnimationFinished});
            this.m_tween.appendMultiple([new Z_TweenLite(this, 0.5, {
                y:(this.y - HEIGHT_OFFSET),
                ease:Back.easeOut
            }), new Z_TweenLite(this, 0.5, {
                y:this.y,
                ease:Back.easeOut
            })], 0, TweenAlign.SEQUENCE);
            this.m_tween.gotoAndPlay(0);
            this.setActive(_arg3);
            if ((((this.m_visibility == VISIBLE_ON_ROLLOVER)) || ((this.m_visibility == NOT_VISIBLE)))){
                this.alpha = 0;
            };
        }
        protected function get slideWidth():int{
            if ((((this.m_slideWidth < 0)) && (!((this.m_bgAsset == null))))){
                return (this.m_bgAsset.width);
            };
            return (this.m_slideWidth);
        }
        protected function get pickWidth():int{
            if (this.m_mainSprite){
                return ((this.m_mainSprite.width - PICK_WIDTH_OFFSET));
            };
            return ((DEFAULT_PICK_WIDTH - PICK_WIDTH_OFFSET));
        }
        protected function get innerYOffset():Number{
            return (INNER_Y_OFFSET);
        }
        public function get mainSprite():Sprite{
            return (this.m_mainSprite);
        }
        public function getMainSpriteRect(_arg1:DisplayObject):Rectangle{
            return (this.m_mainSprite.getRect(_arg1));
        }
        protected function initInner():void{
        }
        protected function rebuildInner():void{
            this.m_innerPanel.removeAll();
            this.initInner();
            this.prepareWindow();
        }
        protected function innerAppend(_arg1:Component, _arg2:Object=null):void{
            this.m_innerPanel.append(_arg1, _arg2);
            ASwingHelper.prepare(this.m_innerPanel);
        }
        protected function innerAppendAll(... _args):void{
            this.m_innerPanel.appendAll.apply(this, _args);
            ASwingHelper.prepare(this.m_innerPanel);
        }
        protected function initPick():void{
            this.m_jpanel = ASwingHelper.makeSoftBoxJPanel();
            this.m_innerMask = new Sprite();
            this.redrawMask();
            addChild(this.m_innerMask);
            this.m_innerSprite.mask = this.m_innerMask;
            this.m_assetPane = new AssetPane(this.m_mainSprite);
            this.m_jpanel.append(this.m_assetPane);
            this.m_jw.setContentPane(this.m_jpanel);
            this.prepareWindow();
            this.m_jw.show();
            this.addEventListener(MouseEvent.MOUSE_OVER, this.removeSelectedItem, false, 0, true);
            addEventListener(MouseEvent.MOUSE_MOVE, this.catchMousePropagation, false, 0, true);
            addEventListener(MouseEvent.CLICK, this.catchMousePropagation, false, 0, true);
        }
        protected function removeSelectedItem(_arg1:Event):void{
            Global.ui.hideAnyToolTip();
        }
        protected function prepareWindow():void{
            if (this.m_jw){
                ASwingHelper.prepare(this.m_jw);
            };
            if (this.m_innerWindow){
                ASwingHelper.prepare(this.m_innerWindow);
            };
            ASwingHelper.prepare(this);
        }
        protected function redrawMask():void{
            this.m_innerMask.graphics.beginFill(0, 1);
            this.m_innerMask.graphics.drawRect(this.pickWidth, INNER_Y_OFFSET, this.slideWidth, this.m_bgAsset.height);
            this.m_innerMask.graphics.endFill();
        }
        protected function init(_arg1:String):void{
            this.m_innerSprite = new Sprite();
            this.m_innerWindow = new JWindow(this.m_innerSprite);
            addChild(this.m_innerSprite);
            this.m_jw = new JWindow(this);
            var _local2:Class = this.getPickBackground();
            var _local3:Class = this.getInnerBackground();
            this.m_mainSprite = new Sprite();
            var _local4:DisplayObject = (new (_local2)() as DisplayObject);
            this.m_mainSprite.addChild(_local4);
            this.m_bgAsset = (new (_local3)() as DisplayObject);
            this.m_innerPanel.setBackgroundDecorator(new AssetBackground(this.m_bgAsset));
            this.m_innerPanel.setPreferredHeight(this.m_bgAsset.height);
            this.m_innerPanel.setMinimumHeight(this.m_bgAsset.height);
            this.m_innerPanel.setMaximumHeight(this.m_bgAsset.height);
            if (_arg1 == null){
                _arg1 = Global.getAssetURL("assets/hud/Friendbar/portrait_noProfileImg.png");
            };
            LoadingManager.load(_arg1, this.onIconLoaded, 0, this.onIconFail);
        }
        protected function onIconFail(_arg1:Event):void{
            var _local2:String = Global.getAssetURL("assets/hud/Friendbar/portrait_noProfileImg.png");
            LoadingManager.load(_local2, this.onIconLoaded);
        }
        protected function getPickBackground():Class{
            return (EmbeddedArt.deliveryPick);
        }
        protected function getInnerBackground():Class{
            return (EmbeddedArt.deliveryInfoField);
        }
        public function setPosition(_arg1:Number, _arg2:Number):void{
            this.x = _arg1;
            this.y = _arg2;
            this.m_tween.kill();
            this.m_tween = null;
            this.m_tween = new TimelineLite({onComplete:this.onAnimationFinished});
            this.m_tween.appendMultiple([new Z_TweenLite(this, 0.5, {
                y:(this.y - HEIGHT_OFFSET),
                ease:Back.easeOut
            }), new Z_TweenLite(this, 0.5, {
                y:this.y,
                ease:Back.easeOut
            })], 0, TweenAlign.SEQUENCE);
            this.m_tween.gotoAndPlay(0);
            this.setActive(this.m_animationActive);
        }
        protected function onIconLoaded(_arg1:Event):void{
            var _local2 = 50;
            var _local3 = 62;
            var _local4 = 72;
            this.m_asset = _arg1.target.loader;
            this.m_asset.width = _local2;
            this.m_asset.height = _local2;
            this.m_asset.x = ((this.m_assetPane.x + (_local3 >> 1)) - (_local2 >> 1));
            this.m_asset.y = ((this.m_assetPane.y + (_local4 >> 1)) - (_local2 >> 1));
            this.m_mainSprite.addChildAt(this.m_asset, 0);
            this.prepareWindow();
        }
        public function set visibility(_arg1:int):void{
            this.m_visibility = _arg1;
            if ((((this.m_visibility == VISIBLE_ON_ROLLOVER)) || ((this.m_visibility == NOT_VISIBLE)))){
                Z_TweenLite.to(this, 0.3, {alpha:0});
            };
        }
        public function showInnerPane():void{
            if (this.m_visibility == VISIBLE_ON_ROLLOVER){
                Z_TweenLite.to(this, 0.3, {alpha:1});
            };
            if (this.m_sliderActive){
                this.m_innerSprite.visible = true;
                this.m_innerMask.visible = true;
                if (this.m_modal){
                    InputManager.disableInput();
                    Global.ui.mouseEnabled = false;
                    Global.ui.mouseChildren = false;
                };
                Z_TweenLite.to(this.m_innerSprite, 0.5, {x:0});
                if (this.m_animationActive){
                    this.m_tween.pause();
                };
            };
        }
        public function hideInnerPane():void{
            if (this.m_visibility == VISIBLE_ON_ROLLOVER){
                Z_TweenLite.to(this, 0.3, {alpha:0});
            };
            if (this.m_sliderActive){
                Z_TweenLite.to(this.m_innerSprite, 0.5, {
                    x:this.m_offXPos,
                    onComplete:this.turnOff
                });
                if (this.m_animationActive){
                    this.m_tween.play();
                };
            };
        }
        private function turnOff():void{
            if (this.alpha > 0){
                this.alpha = 0;
            };
            this.m_innerSprite.visible = false;
            this.m_innerMask.visible = false;
            if (this.m_modal){
                InputManager.enableInput();
                Global.ui.mouseEnabled = true;
                Global.ui.mouseChildren = true;
            };
        }
        public function setActive(_arg1:Boolean, _arg2:Boolean=false):void{
            this.m_animationActive = _arg1;
            if (_arg2){
                this.m_tween.restart();
                this.m_tween.pause();
            };
            if (this.m_animationActive){
                this.m_tween.play();
            } else {
                this.m_tween.pause();
            };
        }
        public function kill(_arg1:Function=null):void{
            var _local2:Object = {alpha:0};
            if (_arg1 != null){
                _local2.onComplete = _arg1;
            };
            Z_TweenLite.to(this, 0.3, _local2);
        }
        private function catchMousePropagation(_arg1:MouseEvent):void{
            Global.ui.turnOffHighlightedObject();
            _arg1.stopPropagation();
        }
        private function onAnimationFinished():void{
            if (this.m_tween){
                this.m_tween.gotoAndPlay(0);
            };
        }
        public function cleanUp():void{
            if (this.m_tween != null){
                this.m_tween.kill();
                this.m_tween = null;
            };
        }

    }
}//package Display.FactoryUI 
